function J = jacobian_circle(X)
%J = jacobian_ellipse(X)
%   X: [phi1 ... phiN, z1, z2, r]
%   J: Jacobi-Matrix an der Stelle X, nach [Gan94], S. 67

X = X';

n_phi = length(X)-3;
phi = X(1:n_phi);
%z = X(end-2:end-1)';
r = X(end);

cp = cos(phi);
sp = sin(phi);

J = zeros(2*n_phi, length(X));

    
temp = [r * sin(phi); -r * cos(phi)];
J(1:2:end,1:n_phi) = diag(temp(1,:));
J(2:2:end,1:n_phi) = diag(temp(2,:));

J(1:2:end, n_phi+1) = -1;

J(2:2:end, n_phi+2) = -1;

J(1:2:end, n_phi +3) = -cp;
J(2:2:end, n_phi +3) = -sp;

J = -J;


% temp = [r * sin(phi); -r * cos(phi)];
% J(1:2:end,1:n_phi) = diag(temp(1,:));
% J(2:2:end,1:n_phi) = diag(temp(2,:));
% 
% J(1:2:end, n_phi+1) = -1;
% 
% J(2:2:end, n_phi+2) = -1;
% 
% J(1:2:end, n_phi +3) = -cp;
% J(2:2:end, n_phi +3) = -sp;

   
    

